package com.ruoyi.develop.factory.factoryTestMachineryCommon.service.impl;

import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.DateUtils;
        import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.ruoyi.develop.factory.factoryTestMachineryCommon.mapper.FactoryTestMachineryCommonMapper;
import com.ruoyi.develop.factory.factoryTestMachineryCommon.domain.FactoryTestMachineryCommon;
import com.ruoyi.develop.factory.factoryTestMachineryCommon.service.IFactoryTestMachineryCommonService;

/**
 * 通用机械试验Service业务层处理
 * @author lmm
 * @date 2025-07-14
 */
@Service
public class FactoryTestMachineryCommonServiceImpl implements IFactoryTestMachineryCommonService {
    @Resource
    private FactoryTestMachineryCommonMapper factoryTestMachineryCommonMapper;

    /**
     * 查询通用机械试验
     * @param id 通用机械试验主键
     * @return 通用机械试验
     */
    @Override
    public FactoryTestMachineryCommon selectById(String id) {
        return factoryTestMachineryCommonMapper.selectById(id);
    }

    /**
     * 查询通用机械试验列表
     * @param entity 通用机械试验
     * @return 通用机械试验
     */
    @Override
    public List<FactoryTestMachineryCommon> selectList(FactoryTestMachineryCommon entity) {
        return factoryTestMachineryCommonMapper.selectList(entity);
    }

    /**
     * 新增通用机械试验
     * @param entity 通用机械试验
     * @return 结果
     */
    @Override
    public int insert(FactoryTestMachineryCommon entity) {
        if(StringUtils.isBlank(entity.getId())){
            entity.setId(IdUtils.fastSimpleUUID());
        }
                entity.setCreateBy(SecurityUtils.getUsername());
                entity.setCreateTime(DateUtils.getNowDate());
            return factoryTestMachineryCommonMapper.insert(entity);
    }

    /**
     * 修改通用机械试验
     * @param entity 通用机械试验
     * @return 结果
     */
    @Override
    public int update(FactoryTestMachineryCommon entity) {
                entity.setUpdateBy(SecurityUtils.getUsername());
                entity.setUpdateTime(DateUtils.getNowDate());
        return factoryTestMachineryCommonMapper.update(entity);
    }

    /**
     * 批量删除通用机械试验
     * @param ids 需要删除的通用机械试验主键
     * @return 结果
     */
    @Override
    public int deleteByIds(String[] ids) {
        return factoryTestMachineryCommonMapper.deleteByIds(ids);
    }

    /**
     * 删除通用机械试验信息
     * @param id 通用机械试验主键
     * @return 结果
     */
    @Override
    public int deleteById(String id) {
        return factoryTestMachineryCommonMapper.deleteById(id);
    }
}
